import request from '@/axios'
import { DictionaryInfoType, DictionaryType, QueryDicType } from './types'

//分页获取字典
export const pageApi = (data) => {
  return request.post({ url: '/dbms-server/base/dictionary/page', data })
}

//删除字典
export const delApi = (params) => {
  return request.delete({ url: '/dbms-server/base/dictionary/delete', params })
}

//获取字典集合
export const listApi = (): Promise<IResponse<DictionaryType[]>> => {
  return request.get({ url: '/dbms-server/base/dictionary/list' })
}

//分页获取字典值
export const pageInfoApi = (data) => {
  return request.post({ url: '/dbms-server/base/dictionaryinfo/page', data })
}

//改变状态
export const checkstateApi = (code) => {
  return request.put({ url: '/dbms-server/base/dictionary/checkstate', params: { code } })
}

//删除字典值
export const delInfoApi = (params) => {
  return request.delete({ url: '/dbms-server/base/dictionaryinfo/delete', params })
}

//获取字典列集合
export const getListDictionaryInfoApi = (
  params: QueryDicType
): Promise<IResponse<DictionaryInfoType[]>> => {
  return request.get({ url: '/dbms-server/base/dictionaryinfo/list', params })
}
//获取字典树集合
export const getTreeDictionaryInfoApi = (
  params: QueryDicType
): Promise<IResponse<DictionaryInfoType[]>> => {
  return request.get({ url: '/dbms-server/base/dictionaryinfo/tree', params })
}

//获取字典树子集
export const getTreeChildDictionaryInfoApi = (
  params: QueryDicType
): Promise<IResponse<DictionaryInfoType[]>> => {
  return request.get({ url: '/dbms-server/base/dictionaryinfo/childs', params })
}
